import { ceil } from './number'

// 文件大小格式化
export const fileSizeFormatter = (size: number) => {
  const chunkSize = 1024

  const units = ['KB', 'MB', 'GB', 'TB', 'PB']

  let index = 0

  while (size >= chunkSize && index < units.length - 1) {
    size /= chunkSize

    index++
  }

  return `${ceil(size, 2)} ${units[index]}`
}

export const fileNameFormatter = () => { }